package controller;


import domain.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import service.ILogin;

import javax.annotation.Resource;

@Controller
public class LoginController {
    @Resource(name="login")
    ILogin login;
//这里省略get、set方法

    @RequestMapping("/long1")//完成登录后台处理
    public String checkUser(User user) {
//        // 使用spring框架加载配置文件
//        ApplicationContext act = new ClassPathXmlApplicationContext("spring.xml");
//        ILogin login = (ILogin) act.getBean("login");
        if (login.execute(user)) {
            return "login_succ";
        }else{
            return "login_err";
        }
    }

    public ILogin getLogin() {
        return login;
    }

    public void setLogin(ILogin login) {
        this.login = login;
    }
}
